package com.fitness.fitness.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fitness.fitness.modal.member.entity.Member;
import com.fitness.fitness.modal.member.param.MemberPageQueryParams;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MemberMapper  extends BaseMapper<Member> {

    @Select("<script>select * from t_member m"
            + " <where>"
            + "<if test='queryParams.keyword != null and queryParams.keyword.trim() neq \"\"'>"
            + " AND m.username like  CONCAT('%',#{queryParams.keyword},'%')"
            + "</if>"
            + "<if test='queryParams.status != null'>"
            + " AND m.status = #{queryParams.status}"
            + "</if>"
            + "</where>"
            +"</script>")
    Page<Member> getMemberPage(Page<Member> page, @Param("queryParams") MemberPageQueryParams queryParams);

    @Select("<script>"
            +" select * from t_member where id in "
            + "<foreach item='mId' open='(' separator=',' close=')' collection='ids'>"
            + "#{mId}"
            + "</foreach>"
            + "</script>")
    List<Member> getMapById(@Param("ids") List<Long> ids);
}
